[][src]Crate ttf_parser

A high-level, safe, zero-allocation TrueType font parser.

Features

  • A high-level API, for people who doesn't know how TrueType works internally. Basically, no direct access to font tables.
  • Zero heap allocations.
  • Zero unsafe.
  • Zero required dependencies. Logging is enabled by default.
  • no_std compatible.
  • Fast.
  • Stateless. All parsing methods are immutable methods.
  • Simple and maintainable code (no magic numbers).

Safety

  • The library must not panic. Any panic considered as a critical bug and should be reported.
  • The library forbids the unsafe code.
  • No heap allocations, so crash due to OOM is not possible.
  • All recursive methods have a depth limit.
  • Technically, should use less than 64KiB of stack in worst case scenario.
  • Most of arithmetic operations are checked.
  • Most of numeric casts are checked.

Error handling

ttf-parser is designed to parse well-formed fonts, so it does not have an Error enum. It doesn't mean that it will crash or panic on malformed fonts, only that the error handling will boil down to Option::None. So you will not get a detailed cause of an error. By doing so we can simplify an API quite a lot since otherwise, we will have to use Result<Option<T>, Error>.

Some methods may print warnings, when the logging feature is enabled.

Modules

name_id

A list of name ID's.

Structs

Class

A value of Class Definition Table.

Font

A font data handle.

GlyphId

A type-safe wrapper for glyph ID.

LineMetrics

A line metrics.

Name

A Name Record.

Names

An iterator over font's names.

Rect

A rectangle.

ScriptMetrics

A script metrics used by subscript and superscript.

Tag

A 4-byte tag.

Variation

A font variation value.

VariationAxes

An iterator over variation axes.

VariationAxis

A variation axis.

Enums

GlyphClass

A glyph class.

PlatformId

A platform ID.

TableName

A table name.

Weight

A font weight.

Width

A font width.

Traits

OutlineBuilder

A trait for glyph outline construction.

Functions

fonts_in_collection

Returns the number of fonts stored in a TrueType font collection.